<!-- Teacher_XueBaSaiFreeChapter.html -->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
	<title>自由课程章节列表</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
	<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
	<!-- <link rel="stylesheet" href="../../css/base.css"/> -->
	<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
	<style type="text/css" media="screen">
		.noSign{
			width: auto;
		}
		.loadFailure{
			width: auto;
		}
		.chapter_cell_left_icon{
			height: 26px;
			margin-right: 10px;
			/*display:block;*/
		}
		.weui_cell_hd{
			height: 26px;
		}
		.weui_cell{
			padding: 15px;
		}
		.mui-table-view-cell.mui-collapse .mui-collapse-content{
			padding: 0;
		}
		.weui_cell:before {
			left: 0;
		}
		.big_chapter_div{
			margin-top: 10px;
		}
		.weui_panel{
			margin-top: 0;
		}
		.weui_cell{
			/*background-color: white;*/
		}
		.fen_ge_xian{
			padding: 1px;
		}
		.base_style_text_color .chapter_title{
			color: #18b4ed;
		}
		.chapter_title{
			line-height: 25px;
			margin-right: 35px;
		}
		.base_content_font {
			font-size: 16px;
		}
		.base_tag_font {
			font-size: 14px;
		}
		.base_title_color_font{
			background-color: #f9f9f9;
		}
		.base_content_color_font{
			/*background-color: #FFFFFF;*/
		}
		.img_margin_left_1{
			margin-left: 16px;
		}
		.img_margin_left_2{
			margin-left: 32px;
		}
		.img_margin_left_3{
			margin-left: 48px;
		}
		.img_margin_left_4{
			margin-left: 64px;
		}
		.mui-btn .btn-img{
			width: 22px;
		}
		.chapter-btn{
			width: 40px;
			height: 25px;
			padding: 2px;
			background-color: #18b4ed;
			border-color: #18b4ed;
			border-radius: 4px;
			color: white;
		}
		.chapter-btn:enabled:active{
			background-color: #08a4dd;
			border-color: #08a4dd;
		}
		.chapter-left-btn{
			float: left;
			margin-right: 10px;
		}
		.chapter-right-btn{
			/*float: right;*/
			margin-left: 50px;
		}
		.cell-right-div{
			width: 40px;
			float: right;
		}
		.cell-double-right-div{
			width: 90px;
			float: right;
		}
		.cell-double-left-div{
			margin-right: 90px;
		}
		.cell-left-div{
			margin-right: 40px;
		}
		.zhang-cell-content{
			height: 25px;
		}
		.zhang-left-div{
			overflow: hidden;
		}
		.zhang-span{
			overflow: hidden;
			text-overflow: -o-ellipsis-lastline;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 1;
			-webkit-box-orient: vertical;
		}
		.mui-switch-mini {
		    width: 42px;
		}
		.mui-switch {
			height: 25px;
		}
		.mui-switch .mui-switch-handle{
			width: 22px;
			height: 22px;
		}
		/*.mui-switch.mui-active {
		    border-color: #18b4ed;
		    background-color: #18b4ed;
		}*/
		.close-cell-bg{
			background-color: #d6d6d6;
		}
		.footer-view{
			position: fixed;
			left: 0;
			bottom: 0;
			margin: 0;
			width: 100%;
			height: 50px;
			padding: 0;
			z-index: 99;
		}
		.footer-view .mui-btn-block{
			width: 100%;
			height: 100%;
			margin: 0;
			padding: 0;
			background-color: #18b4ed;
			border-color: #18b4ed;
			color: white;
			font-size: 16px;
		}
		.footer-view .mui-btn-block:active{
			background-color: #18b4ed;
		}
		.mui-btn, button{
			border-radius: 0px;
		    border-top-left-radius: 0px; 
		    border-top-right-radius: 0px; 
		    border-bottom-right-radius: 0px; 
		    border-bottom-left-radius: 0px; 
		} 
		.blank-div{
			height: 50px;
		}
		.add-btn-div{
			position: fixed;
			right: 100px;
			bottom: 50px;
			width: 80px;
			height: 80px;
		}
		.add-btn{
			width: 100%;
			height: 100%;
		}
		.mui-card {
		    box-shadow: 0px 0px 10px rgba(0,0,0,.1);
		}
		.section-chart{
			width: 80px;
			height: 80px;
		}
		.section-right-div{
			padding: 10px 20px 10px 20px;
			/*padding: 10px 20px 10px 20px; */
			/*height: 60px;*/
			float: right;
			width:-webkit-calc(100% - 80px); 
			width:-moz-calc(100% - 80px); 
			width:calc(100% - 80px); 
		}
		.section-title{
			display: -webkit-box;
			-webkit-box-orient: vertical;
			/*-webkit-line-clamp: 2;*/
			overflow: hidden;
			word-wrap: break-word;
		    white-space: normal; 
		    /*margin-right: 50px;*/
		}
		.cell-right-img{
			width: 20px;
		}
		.zhan-wei-div{
			height: 0;
		}
		.bottom-tiao{
			height: 20px;
		}
		.section-switch-div{
			position: absolute;
			right: 40px;
			/*top: 28px;*/
			top: 20px;
			z-index: 2;
		}
		.mui-btn, button, input[type=button], input[type=reset], input[type=submit]{
			border: 1px solid #18b4ed;
			border-radius: 4px;
		}
		.sub-chapter-chart{
			width: 25px;
			height: 25px;
			position: absolute;
			top: 15px;
			right: 60px;
		}
		.cell-double-left-div .sub-chapter-chart{
			right: 100px;
			margin-right: 10px;
		}
		.section-chart-mask{
			position: absolute;
			width: 80px;
			height: 80px;
			left: 15px;
			top: 11px;
			z-index: 2;
		}
		.chapter-chart-mask{
			position: absolute;
			width: 25px;
			height: 25px;
			top: 15px;
			right: 60px;
		}
		.cell-double-left-div .chapter-chart-mask{
			right: 100px;
			margin-right: 10px;
		}
		.chapter-bg-content{
			background-color: #f0f0f0;
		}
		.base-content .mui-content>.mui-card:first-child{
			margin-top: 10px;
		}
		.base-content .mui-card{
			margin: 10px;
			border-color: #d5d5d5;
			border-radius: 0px;
			border-width: 0px;
		}
		.mui-card .mui-table-view .mui-table-view-cell:first-child, .mui-card .mui-table-view .mui-table-view-divider:first-child{
			border-top-left-radius: 0px;
		    border-top-right-radius: 0px; 
		}
		.mui-navigate-right{
			background-color: white;
		}
		.mui-navigate-right:active{
			background-color: white;
		}
		.folder-content{
			background-color: #f9f9f9;
		}
		.chapter-folder-cell .sub-chapter-chart,.chapter-folder-cell .chapter-chart-mask {
			/*right: 96px;*/
		}
		.chapter-folder-cell .cell-right-img{
			margin-left: 14px;
		}
		.sub-chapter-f-cell .sub-chapter-chart,.sub-chapter-f-cell .chapter-chart-mask {
			/*right: 136px;*/
		}
		.sub-chapter-f-cell .cell-right-img{
			margin-left: 14px;
		}
		.drop-down-tap-div{
			position: absolute;
			right: 0;
			top: 0;
			height: 100%;
			width: 50px;
		}
		.sub-chapter-content-fdiv{
			padding: 0 1px;
		}
		.sub-chapter-content{
			border: 7px solid #ededed;
		}
		.sub-chapter-content-line{
			/*height: 1px;
			width: 100%;
			border-top: 1px solid #dedede;
			-webkit-transform: scaleY(.5);
		    transform: scaleY(.5);*/
		    height: 10px;
		    width: 100%;
		    background-size: 100% 100%;
		    background-image: url(../../image/chapter_background.png);
		}
		.sub-chapter-content-hide{
			display:none;
		}
		/*.weui_cell:before {
		    left: 0;
		    border-top: 1px solid #fff;
		    color: #fff;
		    -webkit-transform: scaleY(.5);
		    transform: scaleY(.5);
		}*/
	</style>
	<link rel="stylesheet" type="text/css" href="../../css/chapterListBewrite.css">
</head>
<body>
	<div class="noSign noDataDiv" hidden="hidden" id="noData">
		<img src="../../image/icon_img.png" width="60%">
		<p class="font16 top_15 base_dark_grey" >
			暂无数据
		</p>
	</div>
	<div class="loadFailure noInternetDiv" hidden="hidden" id="noNet">
		<img src="../../image/icon_img01.png" width="60%">
		<p class="" >
			数据加载失败
		</p>
		<p>
			请检查您的网络
		</p>
		<button type="button" class="mui-btn mui-btn-outlined" onclick="loadChapterData()">
			重新加载
		</button>
	</div>
	<div class="bgcolor base-content">
		<div id="free_chapter_content">

			<!-- <div class="mui-content chapter-bg-content">
				<div class="mui-card">
					<ul class="mui-table-view">
		            	<div class="section-chart-mask" style="background-color: yellow;"></div>
						<li class="mui-table-view-cell mui-collapse">
							<a class="mui-navigate-right">
								<div class="section-right-div">
  									<p class="section-title base_dark_grey base_content_font">
										入库课程介绍
									</p>
  								</div>
  								<div id="chart" class="section-chart" style="background-color: red;"></div>
							</a>
							<div class="mui-collapse-content">
								<div class="weui_cell sub_chapter_cell base_content_color_font sub-chapter-f-cell" >
									<div class="weui_cell_hd">
										<img src="../../image/03.png" alt="" class="chapter_cell_left_icon">
									</div>
									<div class="weui_cell_bd weui_cell_primary">
										<div class="cell-right-div">
											<button class="mui-btn chapter-btn chapter-left-btn">
							            		审阅
							            	</button>
						            	</div>
										<div class="base_grey base_tag_font cell-left-div">
						            		<span class="chapter_title">
							            		调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查调查
						            		</span>
						            		<div id="subChart" class="sub-chapter-chart" style="background-color: red;"></div>
						            		<div class="chapter-chart-mask" style="background-color: yellow;"></div>
						            	</div>
									</div>
									<div id="" class="weui-cell__ft cell-right-down">
										<img class="cell-right-img" src="../../image/icon_bewrite_down.png">
									</div>
									<div class="drop-down-tap-div"></div>
								</div>
								<div class="weui_cell sub_chapter_cell base_content_color_font chapter-folder-cell" >
									<div class="weui_cell_hd">
										<img src="../../image/03.png" alt="" class="chapter_cell_left_icon">
									</div>
									<div class="weui_cell_bd weui_cell_primary">
										<div class="cell-right-div">
										</div>
										<div class="base_grey base_tag_font cell-left-div">
						            		<span class="chapter_title">
							            		调查
						            		</span>
						            		<div id="subChart" class="sub-chapter-chart" style="background-color: red;"></div>
						            		<div class="chapter-chart-mask" style="background-color: yellow;"></div>
						            	</div>
									</div>
									<div id="" class="weui-cell__ft cell-right-down">
										<img class="cell-right-img" src="../../image/icon_bewrite_down.png">
									</div>
								</div>
								<div class="sub-chapter-content">
									<div class="weui_cell base_content_color_font">
										<div class="weui_cell_hd">
											<img src="../../image/icon_chapter_pdf.png" alt="" class="chapter_cell_left_icon">
										</div>
										<div class="weui_cell_bd weui_cell_primary">
											<p class="base_dark_grey base_tag_font">
												<span class="chapter_title">去年买表</span>
											</p>
										</div>
									</div>
									<div class="weui_cell base_content_color_font">
										<div class="weui_cell_hd">
											<img src="../../image/icon_chapter_pdf.png" alt="" class="chapter_cell_left_icon">
										</div>
										<div class="weui_cell_bd weui_cell_primary">
											<p class="base_dark_grey base_tag_font">
												<span class="chapter_title">去年买表</span>
											</p>
										</div>
									</div>
								</div>
							</div>
						</li>
					</ul>
				</div>
			</div> -->

			<!-- <div  class="weui_cell  base_title_color_font class_none">
	          	<div class="weui_cell_bd weui_cell_primary zhang-cell-content">
		          	<div class="cell-right-div">
	            		<div class="mui-switch mui-switch-mini mui-active">
							<div class="mui-switch-handle"></div>
						</div>
	            	</div>
	            	<div class="base_dark_grey base_content_font cell-left-div zhang-left-div">
	            		<span class="chapter_title zhang-span">藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花藏海花</span>
	            	</div>
	          	</div>
	        </div>
	        <div class="weui_cell sub_chapter_cell base_content_color_font" >
				<div class="weui_cell_hd img_margin_left_4">
					<img src="../../image/03.png" alt="" class="chapter_cell_left_icon">
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<div class="cell-right-div">
	            		<div class="mui-switch mui-switch-mini">
							<div class="mui-switch-handle"></div>
						</div>
	            	</div>
					<div class="base_grey base_tag_font cell-left-div">
	            		<span class="chapter_title">调查</span>
	            	</div>
				</div>
			</div>
			<div class="weui_cell sub_chapter_cell base_content_color_font" >
				<div class="weui_cell_hd img_margin_left_2">
					<img src="../../image/03.png" alt="" class="chapter_cell_left_icon">
				</div>
				<div class="weui_cell_bd weui_cell_primary">
					<div class="cell-double-right-div">
						<button class="mui-btn chapter-btn chapter-left-btn">
		            		审阅
		            	</button>
		            	<div class="mui-switch mui-switch-mini chapter-right-btn pub-close-btn">
							<div class="mui-switch-handle"></div>
						</div>
	            	</div>
					<div class="base_grey base_tag_font cell-double-left-div ">
	            		<span class="chapter_title">讨论</span>
	            	</div>
				</div>
			</div> -->
		</div>
		<div class="bottom-tiao"></div>
	</div>
	<div class="blank-div" hidden="hidden"></div>
	<div class="footer-view" hidden="hidden">
		<button id="study_btn" type="button" onclick="onExamClick()" class="mui-btn mui-btn-block">批改考核</button>
	</div>
	<!-- <div id="menu_btn" class="add-btn-div" onclick="menuClick()">
		<img class="add-btn" src="../../image/add_btn.png">
	</div> -->
</body>
<script type="text/javascript" src="../../script/echarts.min.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript" src="../../script/getToken.js"></script>
<script type="text/javascript" src="../../script/setupBewrite.js"></script>
<script type="text/javascript" src="../../script/attachmentManager.js"></script>
<script type="text/javascript" src="../../script/chapterFolder.js"></script>
<script type="text/javascript">
	var chapterArr = new Array();
	var subChapterObjc = new Object();
	var type =0;//判断是否是要重新加载 基数加载  偶数不加载
	var testNum='';//测验章节考试次数
	var firstLoad = true;
	apiready = function(){
		setRefreshHeader();
	 	loadChapterData(); 
	 	setupNotifi();
	 	 SendBehaviorTrajectoriesNotifi(0, '章节列表', '028');
//	 	setupExamBtn();
	}
//	function setupExamBtn(){
//		var pageParam = api.pageParam;
//		var examid = pageParam.examid;
//		if(examid != null && examid != ''){
//			$('.blank-div').show();
//			$('.footer-view').show();
//		}else{
//			$('.blank-div').hide();
//			$('.footer-view').hide();
//		}
//	}
	function setupNotifi(){
		api.addEventListener({
		    name: 'closeMenuNotifi'
		}, function(ret, err) {
		    api.closeFrame({
		        name: 'course_add_menu'
		    });
		    $('#menu_btn').show();
		});
	}
	function onExamClick(){
		api.openWin({useWKWebView:true,
		    name: 'Teacher_CourseTestMakingWindow',
		    url: 'Teacher_CourseTestMakingWindow.html',
		    pageParam: {
		        cid : api.pageParam.courseid,
		        pid : api.pageParam.planid,
		        examid : api.pageParam.examid,
		        type:1//自由课程
		    }
		});
	}
	function ReceNotifi(){
//		api.addEventListener({
//		    name:'RefreshResearchNotifi'
//	    },function(ret,err){
//	    firstLoad = true;
//	    	loadChapterData();
//	    });
//	    api.addEventListener({
//		    name:'RefreshTestNotifi'
//	    },function(ret,err){
//	    firstLoad = true;
//	    	loadChapterData();
//	    });
	}  
	//下拉刷新
	function setRefreshHeader() {
		api.setRefreshHeaderInfo({
			visible : true,
			bgColor : '#ccc',
			textColor : '#fff',
			textDown : '下拉刷新...',
			textUp : '松开刷新...',
			showTime : true
		}, function(ret, err) {
			loadChapterData();
		});
	}
	function loadChapterData() {
		firstLoad = true;
		var params = {
			cid : api.pageParam.courseid
		};
		// alert('url'+url_subChapterUrl+'\n'+JSON.stringify(params));
		cfnetppPOST(url_freeChapterUrl,
		params,
		true,
		function(data, status){
			api.refreshHeaderLoadDone();
			if (status == 'success'){
				if (data.status == true) {
					var chapterlist = data.data;
					if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
						chapterArr = chapterlist;
						setupChapterList();//设置章节列表
						$('.noDataDiv').hide();
						$('.noInternetDiv').hide();
					}else{
						$('.noDataDiv').show();
						$('.noInternetDiv').hide();
					}
				}else{
					api.toast({
					    msg: '自由课程章节列表加载失败'
					});
					$('.noDataDiv').show();
					$('.noInternetDiv').hide();
				}
			}else{
				api.toast({
				    msg: '自由课程章节列表加载失败'
				});
				$('.noDataDiv').hide();
				$('.noInternetDiv').show();
			}
		});
	}
	function setupBigChapterStudiedDetail(chapterid){
		var param = {
			uid : $api.getStorage('cfnetppuid'),
			// jid : $api.getStorage('cfnetppjxid'),
			jid : '419',
			cid : api.pageParam.courseid,
			pid : api.pageParam.planid,
			chapterid : chapterid
		};
		// alert('url:'+url_getSubChapterStudiedDetail+'\n'+JSON.stringify(param));
		cfnetppPOST(url_teacherGetSubChapterStudiedDetail, param, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var chartData = data.data;
					setupChart(chapterid, chartData);
				}else{
					setupChart(chapterid, null);
				}
			}else{
				setupChart(chapterid, null);
			}
		});
	}
	function setupChart(chapterid, data){
		var chartid = 'chart' + chapterid;
		var studiedNum;
		var unStudyNum;
		var percentage;
		var myChart = echarts.init(document.getElementById(chartid));
		if (data == null) {
			studiedNum = 0;
			unStudyNum = 1;
			percentage = '0%';//百分比
		}else{
			var stuList = data.study;
			if (stuList != undefined && stuList != null && stuList.constructor == Array && stuList.length > 0) {
				var studentNum = data.studynum.toString();
				var allChapterNum = data.allchapternum.toString();
				var tempAllNum = studentNum * allChapterNum;
				var tempStudiedNum = 0;
				for (var i = 0; i < stuList.length; i++) {
					var stuData = stuList[i];
					var stuNum = stuData.num;
					tempStudiedNum += stuNum;
				}
				studiedNum = parseFloat(tempStudiedNum);
				var allNum = parseFloat(tempAllNum);
				if (allNum < studiedNum) {
					allNum = studiedNum;
				}
				if (allNum == 0) {
					allNum = 1;
				}
				unStudyNum = allNum - studiedNum;
				percentageNum = (studiedNum / allNum) * 100;
				percentage = percentageNum.toFixed(0) + '%'; 
			}else{
				studiedNum = 0;
				unStudyNum = 1;
				percentage = '0%';//百分比
			}
		}
		myChart.setOption({
			title: {
		        text: percentage,
		        x: 'center',
		        y: 'center',
		        textStyle:{
			        //文字颜色
			        color:'#666',
			        //字体风格,'normal','italic','oblique'
			        fontStyle:'normal',
			        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
			        fontWeight:'bold',
			        //字体系列
			        fontFamily:'sans-serif',
			        //字体大小
			　　　　 fontSize:14
			    }
		    },
			series: [
			    {
			        type:'pie',
			        radius: ['70%', '100%'],
			        avoidLabelOverlap: true,
			        label: {
			            normal: {
			                show: true,
			                position: 'center'
			            },
			            emphasis: {
			                show: true
			            }
			        },
			        labelLine: {
			            normal: {
			                show: true
			            }
			        },
			        data:[
			            {value:studiedNum},
			            {value:unStudyNum}
			        ],
			        color:['#18b4ed', '#d0d0d0']
			    }
			]
		});
	}
	//设置第二子章节
	function setupChildChapterList(prefix, chapterid, type) {
		var params = {
			cid : api.pageParam.courseid,
			pid : chapterid,
			uid : $api.getStorage('cfnetppuid'),
			jhid : api.pageParam.planid
		};
		// alert('url'+url_subChapterUrl+'\n'+JSON.stringify(params));
		cfnetppPOST(url_subChapterUrl, params, true, function(data, status) {
			// alert(JSON.stringify(data));
			if (status == 'success') {
				if (data.status == true) {
					var chapterlist = data.data;
					if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
						//设置子章节列表
						setupSubChapterList(prefix, chapterlist);
					}
				} else {
					// api.toast({
					//     msg: '自由课程章节列表加载失败'
					// });
				}
			} else {
				// api.toast({
				//     msg: '自由课程章节列表加载失败'
				// });
			}
		});
	}
	//设置第二子章节
	function setupChildChapterList_old(prefix, chapterid, type){
		$('.div_after').hide();
	    if($(type).hasClass("class_none") || prefix == 1){
	    	if (prefix == 1) {
	    		if (firstLoad == true) {
	    			firstLoad = false;
	    		}else{
	    			$(type).next('.div_after').show();
	    			return;
	    		}
				$('#'+chapterid).removeClass("class_none");
	    	}
	        var params = {
				cid : api.pageParam.courseid,
				pid : chapterid,
				uid : $api.getStorage('cfnetppuid'),
				jhid :api.pageParam.planid
			};
			// alert('url'+url_subChapterUrl+'\n'+JSON.stringify(params));
			cfnetppPOST(url_subChapterUrl,
			params,
			true,
			function(data, status){
			// alert(JSON.stringify(data));
				if (status == 'success'){
					if (data.status == true) {
						var chapterlist = data.data;
						if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
							setupSubChapterList(prefix, chapterlist);//设置子章节列表
						}
					}else{
						// api.toast({
						//     msg: '自由课程章节列表加载失败'
						// });
					}
				}else{
					// api.toast({
					//     msg: '自由课程章节列表加载失败'
					
					// });
				}
			});
			$(type).removeClass("class_none");
	    }
	    // $(window).scrollTop(44);
	    // $(type).next('.div_after').show('fast', function() {
	    	
	    // });;
	    $(type).next('.div_after').show();
		// $(type).next('.div_after').toggle();
	     
	}
	
	
	//设置第三子章节列表
	function childsetupChildChapterList(prefix, chapterid){
	    var params = {
			cid : api.pageParam.courseid,
			pid : chapterid,
			uid : $api.getStorage('cfnetppuid'),
			jhid :api.pageParam.planid
		};
		cfnetppPOST(url_subChapterUrl,
		params,
		true,
		function(data, status){
			if (status == 'success'){
				if (data.status == true) {
					var chapterlist = data.data;
					if (chapterlist != null && chapterlist.constructor == Array && chapterlist.length > 0) {//判断章节数组是否有效
						setchildupSubChapterList(prefix, chapterlist);//设置子章节列表
					}
				}else{
					// api.toast({
					//     msg: '自由课程章节列表加载失败'
					// });
				}
			}else{
				// api.toast({
				//     msg: '自由课程章节列表加载失败'
				// });
			}
		});
	}
	//设置章节列表
	function setupChapterList(){
		$('#free_chapter_content').html('');
		for (var i = 0; i < chapterArr.length; i++) {
			var chapterData = chapterArr[i];
			var chapterHtmlStr = sectionHtmlWithData(i+1,chapterData);
//			alert(chapterHtmlStr);
			$('#free_chapter_content').append(chapterHtmlStr);//拼接章html串
			if (i == 0) {
				$('#section_tap'+chapterData.id).addClass('mui-active');
			}
			setupBigChapterStudiedDetail(chapterData.id);
			setupPubClick();
			// alert(JSON.stringify(chapterData));
			// if (parseInt(chapterData.child) > 0) {
				setupChildChapterList(i + 1, chapterData.id);
			// }
		}
		//设置饼图点击事件
		// setupChartTapClick();
	}
	//设置第二子章节列表
	function setupSubChapterList(prefix, chapterlist){
		// var chapterContainerId = '#container' + chapterlist[0].id;
		var subChapterHtmlStr = '';
		for (var i = 0; i < chapterlist.length; i++) {
			var chapterData = chapterlist[i];
			subChapterObjc[chapterData.id] = chapterData;
			var chapterHtml = cellHtmlWithData(prefix, i + 1, chapterData);
			subChapterHtmlStr += chapterHtml;
			if (parseInt(chapterData.child) > 0) {
				childsetupChildChapterList(prefix + '.' + (i + 1), chapterData.id);
			}
		}
		$('#aft_chapterid' + chapterData.pid).after(subChapterHtmlStr);
		for (var i = 0; i < chapterlist.length; i++) {
			var chapterData = chapterlist[i];
			getSubChapterStudiedInfo(chapterData.id);
		}
		// $('#' + chapterData.pid).after('<div class="div_after">'+subChapterHtmlStr+'</div>');
		setSubChapterClick();
		setupBewriteClick();
	}
		//设置第三子章节列表
	function setchildupSubChapterList(prefix, chapterlist){

		var subChapterHtmlStr = '';
		for (var i = 0; i < chapterlist.length; i++) {
			var chapterData = chapterlist[i];
			subChapterObjc[chapterData.id] = chapterData;
			var chapterHtml = cellHtmlWithData(prefix, i + 1, chapterData);
			subChapterHtmlStr += chapterHtml;
			if (parseInt(chapterData.child) > 0) {
				childsetupChildChapterList(prefix + '.' + (i + 1), chapterData.id);
			}
		}
		$('#aft_chapterid' + chapterData.pid).after(subChapterHtmlStr);
		for (var i = 0; i < chapterlist.length; i++) {
			var chapterData = chapterlist[i];
			getSubChapterStudiedInfo(chapterData.id);
		}
		// $('#' + chapterData.pid).after(subChapterHtmlStr);
		setSubChapterClick();
		setupBewriteClick();
	}
	function sectionHtmlWithData(index, data){
		var trainsObj = new GB2312UTF8();
		var isclose = data.isclose;
		var pubImg = 'public';
		var switchClass = '';
		var switchBGClass = ' close-cell-bg';
		if (isclose == 0) {//已发布
			pubImg = 'close';
			switchClass = ' mui-active';
			switchBGClass = '';
		}
		// return '<div id="'+data.id+'" class="weui_cell  base_title_color_font class_none"  onclick="setupChildChapterList('+index +","+"'"+data.id+ "'"+","+'this)">'+
	 //          	'<div class="weui_cell_bd weui_cell_primary">'+
	 //            	'<p class="base_dark_grey base_content_font">'+
	 //            		// '<span>第'+index+'章</span>'+
	 //            		'<span class="chapter_title">'+trainsObj.Utf8ToGb2312(data.cdetailtitle)+'</span>'+
	 //            	'</p>'+
	 //          	'</div>'+
	 //        '</div>';
//	        '<div class="weui_cell fen_ge_xian"></div>  <div>';
		var pubClass = 'pubClass' + index;
	    // return '<div id="'+data.id+'" class="weui_cell base_title_color_font class_none'+switchBGClass+'" onclick="setupChildChapterList('+index +","+"'"+data.id+ "'"+","+'this)">'+
	    //       	'<div class="weui_cell_bd weui_cell_primary zhang-cell-content">'+
		   //        	'<div class="cell-right-div">'+
	    //         		// '<button pubClass="'+pubClass+'" pubType="zhang" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="pub-close-btn mui-btn chapter-btn chapter-right-btn '+pubClass+'">'+
		   //          	// 	'<img id="pubImg'+data.id+'" class="btn-img" src="../../image/icon_'+pubImg+'.png"/>'+
		   //          	// '</button>'+
		   //          	// '<div pubClass="'+pubClass+'" pubType="zhang" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="mui-switch mui-switch-mini pub-close-btn '+pubClass+switchClass+'">'+
		   //          	'<div pubClass="'+pubClass+'" pubType="zhang" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="mui-switch mui-switch-mini pub-close-btn '+pubClass+switchClass+'">'+
					// 		'<div class="mui-switch-handle"></div>'+
					// 	'</div>'+
	    //         	'</div>'+
	    //         	'<div class="base_dark_grey base_content_font cell-left-div zhang-left-div">'+
	    //         		'<span class="chapter_title zhang-span">'+trainsObj.Utf8ToGb2312(data.cdetailtitle)+'</span>'+
	    //         	'</div>'+
	    //       	'</div>'+
	    //     '</div>';
	    return '<div chapterid="'+data.id+'" index="'+index+'" class="mui-content chapter-bg-content section-cell">'+
					'<div class="mui-card">'+
						'<ul class="mui-table-view">'+
							// '<div class="section-switch-div">'+
			    //         		'<div pubClass="'+pubClass+'" pubType="zhang" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="mui-switch mui-switch-mini pub-close-btn '+pubClass+switchClass+'">'+
							// 		'<div class="mui-switch-handle"></div>'+
							// 	'</div>'+
			    //         	'</div>'+
			            	'<div chapterid="'+data.id+'" class="section-chart-mask"></div>'+
							'<li id="section_tap'+data.id+'" class="mui-table-view-cell mui-collapse">'+
								'<a class="mui-navigate-right">'+
									'<div class="section-right-div">'+
      									'<p class="section-title base_dark_grey base_content_font">'+
											trainsObj.Utf8ToGb2312(data.cdetailtitle)+
										'</p>'+
      								'</div>'+
      								'<div id="chart'+data.id+'" class="section-chart"></div>'+
								'</a>'+
								'<div class="mui-collapse-content">'+
									'<div class="zhan-wei-div" id="aft_chapterid' + data.id + '">'+
								'</div>'+
							'</li>'+
						'</ul>'+
					'</div>'+
				'</div>';
	}
	function imagePathWithUrlPath(fileName){
		var fileSuffix = fileSuffixWithPath(fileName);
		if (fileSuffix == '.doc' || fileSuffix == '.docx') {
			return '../../image/icon_chapter_doc.png';
		}else if(fileSuffix == '.pdf'){
			return '../../image/icon_chapter_pdf.png';
		}else if(fileSuffix == '.xls' || fileSuffix == '.xlsx'){
			return '../../image/icon_chapter_excel.png';
		}else if(fileSuffix == '.ppt' || fileSuffix == '.pptx'){
			return '../../image/icon_chapter_ppt.png';
		}else if(fileSuffix == '.png' || fileSuffix == '.jpg' || fileSuffix == '.jpeg' || fileSuffix == '.bmp' || fileSuffix == '.gif'){
			return '../../image/icon_chapter_img.png';
		}else if(fileSuffix == '.mp4' || fileSuffix == '.avi' || fileSuffix == '.rmvb' || fileSuffix == '.3gp' || fileSuffix == '.flv'){
			return '../../image/09.png';
		}else{
			return '../../image/011.png';
		}
	}
	function fileSuffixWithPath(path){
		var result =/\.[^\.]+/.exec(path);
		return result;
	}
	function cellHtmlWithData(prefix, index, data){
		var content_type = data.content_type;
		var isclose = data.isclose;
		var pubImg = 'public';
		var switchClass = '';
		var switchBGClass = ' close-cell-bg';
		if (isclose == 0) {//已发布
			pubImg = 'close';
			switchClass = ' mui-active';
			switchBGClass = '';
		}
		var leftBtn = '';
		var rightDivClass = 'cell-right-div';
		var leftDivClass = 'cell-left-div';
		var imgSrc = '';
		var rightBtnClass = '';
		var folderRightImage = '';
		var folderContentDiv = '';
		var folderClass = '';
		var subChapterToggleDiv = '';
		if (parseInt(data.child) > 0) {//如果有子章节
			subChapterToggleDiv = '<div chapterid="'+data.id+'" class="drop-down-tap-div sub-chapter-hide"></div>';
			folderRightImage = '<div class="weui-cell__ft cell-right-down">'+
									'<img id="folder_right_img'+data.id+'" class="cell-right-img" src="../../image/icon_bewrite_down.png">'+
								'</div>';
			if (content_type == 'tests' || content_type == 'works') {
				folderClass = ' sub-chapter-f-cell';
			}else{
				folderClass = ' chapter-folder-cell';
			}
		}
		if (content_type == 'richtext') {//富文本
			if (data.rid == '') {//富文本
				imgSrc = '../../image/08.png';
			}else{//视频
				imgSrc = '../../image/09.png';
			}
		}else if(content_type == 'survey'){//调查
			imgSrc = '../../image/03.png';
		}else if(content_type == 'tests'){//测验
			imgSrc = '../../image/01.png';
			leftBtn = '<button onclick="testBtnClick('+data.id+', event)" class="mui-btn chapter-btn chapter-left-btn">批卷</button>';
			// rightDivClass = 'cell-double-right-div';
			// leftDivClass = 'cell-double-left-div';
			rightDivClass = 'cell-right-div';
			leftDivClass = 'cell-left-div';
			rightBtnClass = ' chapter-right-btn';
		}else if(content_type == 'discuss'){//讨论 
			imgSrc = '../../image/02.png';
		}else if(content_type == 'works'){//作业
			imgSrc = '../../image/04.png';
			leftBtn = '<button onclick="workBtnClick('+data.id+', event)" class="mui-btn chapter-btn chapter-left-btn">审阅</button>';
			// rightDivClass = 'cell-double-right-div';
			// leftDivClass = 'cell-double-left-div';
			rightDivClass = 'cell-right-div';
			leftDivClass = 'cell-left-div';
			rightBtnClass = ' chapter-right-btn';
		}else if(content_type == 'folder'){//文件夹
			imgSrc = '../../image/010.png';
			folderRightImage = '<div class="weui-cell__ft cell-right-down">'+
										'<img id="folder_right_img'+data.id+'" class="cell-right-img" src="../../image/icon_bewrite_down.png">'+
									'</div>';
			folderContentDiv = '<div id="folder_file_div'+data.id+'" class="folder-content"></div>';
			folderClass = ' chapter-folder-cell';
		}else if(content_type == 'files'){//文件
			// imgSrc = '../../image/011.png';
			var rid = data.rid;
			var ridArr = rid.split('||');
			var fileName = ridArr[0];
			imgSrc = imagePathWithUrlPath(fileName);
		}else if(content_type == 'sitenow'){//现场实操 
			imgSrc = '../../image/05.png';
			//评分暂不显示
			// leftBtn = '<button onclick="sitenowBtnClick('+data.id+', event)" class="mui-btn chapter-btn chapter-left-btn">评分</button>';
			// rightDivClass = 'cell-double-right-div';
			// leftDivClass = 'cell-double-left-div';
		}else if(content_type == 'hdresource'){//互动资源
			imgSrc = '../../image/06.png';
		}else if(content_type == 'sysdeal'){//系统处理
			imgSrc = '../../image/icon_scorm.png';
		}else if(content_type == 'flash'){//flash动画
			imgSrc = '../../image/icon_flash.png';
		}else if(content_type == 'tag'){
			imgSrc = '../../image/07.png';
		}else{
			imgSrc = '../../image/icon_scorm.png';
		}
		var index_i =prefix + '.' + index;
		var preArr = index_i.split(".");
		var marginLeftClass = '';
		//屏蔽掉右缩进
		// if (preArr.length == 0 || preArr.length == 1) {
			
		// }else if(preArr.length == 2){
		// 	// marginLeftClass = " img_margin_left_1";
		// }else if(preArr.length == 3){
		// 	// marginLeftClass = " img_margin_left_2";
		// 	marginLeftClass = " img_margin_left_1";
		// }else if(preArr.length == 4){
		// 	// marginLeftClass = " img_margin_left_3";
		// 	marginLeftClass = " img_margin_left_1";
		// }else{
		// 	// marginLeftClass = " img_margin_left_4";
		// 	marginLeftClass = " img_margin_left_1";
		// }

		 // onclick="setupChildChapterList(' + index_i +","+"'"+data.id+ "'"+","+"'"+1+ "'"+')"
		// return '<div id="'+data.id+'" class="weui_cell sub_chapter_cell base_content_color_font" >'+
		// 		'<div class="weui_cell_hd'+marginLeftClass+'">'+
		// 			'<img src="'+imgSrc+'" alt="" class="chapter_cell_left_icon">'+
		// 		'</div>'+
		// 		'<div class="weui_cell_bd weui_cell_primary">'+
		// 			'<p class="base_grey base_tag_font">'+
	 //            		// '<span>('+prefix+'.'+index+')</span>'+
	 //            		'<span class="chapter_title">'+data.cdetailtitle+'</span>'+
	 //            	'</p>'+
		// 		'</div>'+
		// 	'</div>';
		var pubClass = '';
		var pubClassStr = 'pubClass';
		for (var i = 0; i < preArr.length; i++) {
			var preindex = preArr[i];
			pubClassStr += preindex;
			pubClass += ' ' + pubClassStr;
		}
		// var pubClass = 'pubClass' + prefix.toString().substr(0, 1);//用于整体修改子章节的状态
		var pubImgClass = pubClass + 'img';

		//描述
		var bwriteHtml = bewriteHtmlWithData(data);
		// var afterHtml = '<div id="subChapterContent'+data.id+'" class="sub-chapter-content sub-chapter-content-hide">'+
		// 					'<div class="sub-chapter-content-line"></div>'+
		// 					'<div id="aft_chapterid'+data.id+'" hidden="hidden"></div>'+
		// 					'<div class="sub-chapter-content-line"></div>'+
		// 				'</div>';
		var afterHtml = '<div id="subChapterContent'+data.id+'" class="sub-chapter-content-hide sub-chapter-content-fdiv">'+
							'<div class="sub-chapter-content-line"></div>'+
							'<div class="sub-chapter-content">'+
								'<div id="aft_chapterid'+data.id+'" hidden="hidden"></div>'+
							'</div>'+
						'</div>';
		return	'<div id="'+data.id+'" class="weui_cell sub_chapter_cell base_content_color_font'+switchBGClass+folderClass+'" >'+
				'<div class="weui_cell_hd'+marginLeftClass+'">'+
					'<img src="'+imgSrc+'" alt="" class="chapter_cell_left_icon">'+
				'</div>'+
				'<div class="weui_cell_bd weui_cell_primary">'+
					'<div class="'+rightDivClass+'">'+
							leftBtn+
	            		// '<button pubType="jie" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="pub-close-btn mui-btn chapter-btn chapter-right-btn '+pubClass+'">'+
		            	// 	'<img id="pubImg'+data.id+'" class="btn-img '+pubImgClass+'" src="../../image/icon_'+pubImg+'.png" />'+
		            	// '</button>'+
		    //         	'<div pubClass="'+pubClass+'" pubType="jie" id="pubBtn'+data.id+'" isclose="'+isclose+'" vid="'+data.id+'" class="mui-switch mui-switch-mini pub-close-btn '+pubClass+switchClass+rightBtnClass+'">'+
						// 	'<div class="mui-switch-handle"></div>'+
						// '</div>'+
	            	'</div>'+
					'<div class="base_grey base_tag_font '+leftDivClass+'">'+
	            		'<span class="chapter_title">'+data.cdetailtitle+'</span>'+
	            		'<div id="subChart'+data.id+'" class="sub-chapter-chart"></div>'+
	            		'<div class="chapter-chart-mask"></div>'+
	            	'</div>'+
				'</div>'+
				folderRightImage+
				subChapterToggleDiv+
			'</div>'+
			bwriteHtml+
			folderContentDiv+
			afterHtml;
	}
	function getSubChapterStudiedInfo(chapterid){
		var param = {
			uid : $api.getStorage('cfnetppuid'),
			// jid : $api.getStorage('cfnetppjxid'),
			jid : '419',
			pid : api.pageParam.planid,
			cid : api.pageParam.courseid,
			chapterid : chapterid
		};
		cfnetppPOST(url_subChapterStudiedInfo, param, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var subChartData = data.data;
					setupSubChart(chapterid, subChartData);
				}else{
					setupSubChart(chapterid, null);
				}
			}else{
				setupSubChart(chapterid, null);
			}
		});
	}
	function setupSubChart(chapterid, subChartData){
		var chartid = 'subChart' + chapterid;
		var myChart = echarts.init(document.getElementById(chartid));
		var studiedNum;
		var unStudyNum;
		var percentage;
		if (subChartData == null) {
			studiedNum = 0;
			unStudyNum = 1;
			percentage = "0%";
		}else{
			studiedNum = parseFloat(subChartData.studiedstunum.toString());
			var allNum = parseFloat(subChartData.allstunum.toString());
			if (allNum < studiedNum) {
				allNum = studiedNum;
			}
			if (allNum == 0) {
				allNum = 1;
			}
			unStudyNum = allNum - studiedNum;
			percentageNum = (studiedNum / allNum) * 100;
			percentage = percentageNum.toFixed(0) + '%';
		}
		myChart.setOption({
			title: {
		        text: percentage,
		        x: 'center',
		        y: 'center',
		        textStyle:{
			        //文字颜色
			        color:'#666',
			        //字体风格,'normal','italic','oblique'
			        fontStyle:'normal',
			        //字体粗细 'normal','bold','bolder','lighter',100 | 200 | 300 | 400...
			        fontWeight:'bold',
			        //字体系列
			        fontFamily:'sans-serif',
			        //字体大小
			　　　　 fontSize:8
			    }
		    },
			series: [
			    {
			        type:'pie',
			        radius: ['0%', '100%'],
			        avoidLabelOverlap: true,
			        label: {
			            normal: {
			                show: true,
			                position: 'center'
			            },
			            emphasis: {
			                show: true
			            }
			        },
			        labelLine: {
			            normal: {
			                show: true
			            }
			        },
			        data:[
			            {value:studiedNum},
			            {value:unStudyNum}
			        ],
			        color:['#18b4ed', '#d0d0d0']
			    }
			]
		});
	}
	//测验审阅
	function testBtnClick(chapterid, event){
	 	var subChapterData = subChapterObjc[chapterid];
	 	//todo
	 	event.stopPropagation();

		api.openWin({useWKWebView:true,
	        name : 'Teacher_TestMarkingManageWindow',
		    url : '../Teacher_Teach/Teacher_TestMarkingManageWindow.html',
		    pageParam: {
	   　　　	vid :subChapterData.id,
			    pid : api.pageParam.planid,
			    cid  :api.pageParam.courseid,
			    bewrite :subChapterData.bewrite,
				is_dis_bewrite :subChapterData.is_dis_bewrite,
				title :subChapterData.title
		 	}
        });
	}

	function workBtnClick(chapterid, event){
		event.stopPropagation();
		var subChapterData = subChapterObjc[chapterid];
		api.openWin({useWKWebView:true,
			name : 'Teacher_HomeWorkMarkingManage_StudentWindow',
			url : 'Teacher_HomeWorkMarkingManage_StudentWindow.html',
			pageParam : {
				vid : subChapterData.id,
		        pid : api.pageParam.planid,
		        cid : api.pageParam.courseid,
		        wid : subChapterData.rid
			}
		});
	}
	//现场实操评分
	function sitenowBtnClick(chapterid, event){
		var subChapterData = subChapterObjc[chapterid];
		//todo
		event.stopPropagation();
	}
	//发布章节
	function pubZhangJie(pubClass, vid, pubStatus){
		var pubParams = {
			jid : $api.getStorage('cfnetppjxid'),
			uid : $api.getStorage('cfnetppuid'),
			cid : api.pageParam.courseid,
			vid : vid,
			isclose : pubStatus
		};
		var pubClassArr = pubClass.split(" ");
		var currentPubClass = pubClassArr[pubClassArr.length-1];
		var thePreviousPubClass = pubClassArr[pubClassArr.length-2];

		// alert('url:'+url_closeOfOpenChapter+'\n'+JSON.stringify(pubParams));
		cfnetppPOST(url_closeOfOpenChapter, pubParams, false, function(data, status){
			SendBusinessOperationsLogNotifi('自由课程章节列表页', '028', pubParams, pubParams, '', data, '自由课程发布关闭章节接口', '028-01')
			if (status == 'success') {
				if (data.code == 200) {
					api.toast({
					    msg: '操作成功'
					});
					if (pubStatus == 1) {//关闭
						// $('#pubBtn' + vid).attr('isclose', '1');
						// $('#pubBtn' + vid).removeClass('mui-active');
						$('.' + currentPubClass).attr('isclose', '1');
						$('.' + currentPubClass).removeClass('mui-active');
						$('.' + currentPubClass).parents('.weui_cell').addClass('close-cell-bg');
						var allCloseStatus = 0;
						var j = 0;
						$('.' + thePreviousPubClass).each(function(){
							if($(this).attr('isclose') == '0'){
								if (j > 0) {
									allCloseStatus++;
								}
								j++;
							}
						});
						if (allCloseStatus == 0) {//全部已关闭
							$('.' + thePreviousPubClass).attr('isclose', '1');
							$('.' + thePreviousPubClass).removeClass('mui-active');
							$('.' + thePreviousPubClass).parents('.weui_cell').addClass('close-cell-bg');
						}
					}else{
						$('#pubBtn' + vid).attr('isclose', '0');
						// $('#pubImg' + vid).attr('src', '../../image/icon_close.png');
						$('#pubBtn' + vid).addClass('mui-active');
						$('.' + currentPubClass).attr('isclose', '0');
						// $('.' + pubClass + 'img').attr('src', '../../image/icon_close.png');
						$('.' + currentPubClass).addClass('mui-active');
						$('.' + currentPubClass).parents('.weui_cell').removeClass('close-cell-bg');
						var allCloseStatus = 0;
						var j = 0;
						$('.' + thePreviousPubClass).each(function(){
							if($(this).attr('isclose') == '1'){
								if (j > 0) {
									allCloseStatus++;
								}
								j++;
							}
						});
						if (allCloseStatus == 0) {//全部已关闭
							$('.' + thePreviousPubClass).attr('isclose', '0');
							$('.' + thePreviousPubClass).addClass('mui-active');
							$('.' + thePreviousPubClass).parents('.weui_cell').removeClass('close-cell-bg');
						}
					}
				}else{
					api.toast({
					    msg: '操作失败，请重试'
					});
					//操作失败则复原
					if (pubStatus == 1) {//关闭
						$('#pubBtn' + vid).addClass('mui-active');
					}else{
						$('#pubBtn' + vid).removeClass('mui-active');
					}
				}
			}else{
				api.toast({
				    msg: '操作失败，请重试'
				});
				//操作失败则复原
				if (pubStatus == 1) {//关闭
					$('#pubBtn' + vid).addClass('mui-active');
				}else{
					$('#pubBtn' + vid).removeClass('mui-active');
				}
			}
		});
	}
	function setupChartTapClick(){
		$('.section-chart-mask').unbind('click');
		$('.section-chart-mask').click(function(){
			var chapterid = $(this).attr('chapterid');
			api.openWin({useWKWebView:true,
			    name: 'StatisticalAnalysisWindow',
			    url: '../CourseManage/StatisticalAnalysisWindow.html ',
			    pageParam: {
			        vid : chapterid,
			        cid : api.pageParam.courseid,
			        pid : api.pageParam.planid
			    }
			});
		});
	}
	function setSubChapterClick(){
		$('.sub_chapter_cell').unbind('click');
		$('.sub_chapter_cell').click(function(){
			$('.sub_chapter_cell').removeClass('base_style_text_color');
			$(this).addClass('base_style_text_color');
			var chapterid = $(this).attr('id');
			var subChapterData = subChapterObjc[chapterid];
			pushToNextWindow(subChapterData);
		});
		setupPubClick();
		$('.bewrite-cell').unbind('click');
		$('.bewrite-cell').click(function(){
			var chapterid = $(this).attr('chapterid');
			$('.sub_chapter_cell').removeClass('base_style_text_color');
			$('#'+chapterid).addClass('base_style_text_color');
			var subChapterData = subChapterObjc[chapterid];
			pushToNextWindow(subChapterData);
			// var isTag = $(this).attr('isTag');
			// if (isTag == '1') {
				
			// }
		});
		$('.drop-down-tap-div').unbind('click');
		$('.drop-down-tap-div').click(function(event){
			var chapterid = $(this).attr('chapterid');
			if ($(this).hasClass('sub-chapter-hide')) {
				$(this).removeClass('sub-chapter-hide');
				$('#subChapterContent'+chapterid).removeClass('sub-chapter-content-hide');
				$('#folder_right_img'+chapterid).attr('src', '../../image/icon_bewrite_up.png');
			}else{
				$(this).addClass('sub-chapter-hide');
				$('#subChapterContent'+chapterid).addClass('sub-chapter-content-hide');
				$('#folder_right_img'+chapterid).attr('src', '../../image/icon_bewrite_down.png');
			}
			event.stopPropagation();
		});
	}
	function setupPubClick(){
		$('.pub-close-btn').unbind('click');
		$('.pub-close-btn').click(function(event){
			var status = 0;//发布
			if ($(this).attr('isclose') == 0) {//已发布状态
				status = 1;//关闭
				$(this).removeClass('mui-active');
			}else{
				$(this).addClass('mui-active');
			}
			var chapterid = $(this).attr('vid');
			var pubType = $(this).attr('pubType');
			var pubClass = $(this).attr('pubClass');
			pubZhangJie(pubClass, chapterid, status);
			event.stopPropagation();
		});
	}
	//根据类型跳转页面
	function pushToNextWindow(data){
		var pid = api.pageParam.planid;
		var cType = data.content_type;
		var winName = '';
		var isclose = data.isclose;
		var bewrite =data.bewrite;
			// if (isclose == '1') {
			// 	api.toast({
			// 	    msg: '该课时尚未发布，暂不能学习',
			// 	    duration: 3000,
			// 	    location: 'bottom'
			// 	});
			// 	return;
			// }
		var is_encr = data.is_encr;
		var baidu_cloud_id_url = data.baidu_cloud_id_url;
		var baidu_cloud_id = data.baidu_cloud_id;
		var pageParam = new Object();
		if (cType == 'richtext') {//富文本
//		  if(bewrite.length >0){
//			  	winName = 'Student_Free_bewrite';
//	
//			}else{
			if (data.rid == '') {//富文本
				winName = 'studyCourseRichtextNew';
				
			}else{//视频
				// winName = 'Student_FreeCourseVideo';
				// pageParam = {
				// 	videourl : data.rid,
				// 	videoname : data.cdetailtitle
				// };
				var connectionType = api.connectionType;
	            if (connectionType != 'wifi' && connectionType != 'none') {
	            	api.confirm({
	                    title: '提示',
	                    msg: '您当前处于移动数据网络下，是否继续播放',
	                    buttons: ['确定', '取消']
	                }, function(ret, err) {
	                    var index = ret.buttonIndex;
	                    if (index == 1) {//确定
	                        // toPlayVideo(data);
	                        pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, data.rid, data.cdetailtitle);
	                    }
	                });
	            }else{
	            	// toPlayVideo(data);
	            	pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, data.rid, data.cdetailtitle);
	            }
				return;
			}
//			}
			pageParam = {
				chapterid : data.id,
				cdetailtitle : data.cdetailtitle,
				richtextType : 1,
				other :data.other,
				bewrite:data.bewrite,
				is_dis_bewrite :data.is_dis_bewrite,
				content_type :cType,
				rid : data.rid
			};
		}else if(cType == 'survey'){//调查
		 //  if(bewrite.length >0){
			//   	winName = 'Student_Free_bewrite';
			//   	pageParam = {
			//          id : data.id,
			// 		pid : pid,
			// 		cid : data.cid,
			// 		cdetailtitle : data.cdetailtitle,
			// 		rid : data.rid,
			// 		bewrite : data.bewrite,
			// 	    is_dis_bewrite :data.is_dis_bewrite,
			// 	    content_type :cType
			//     };
	
			// }else{
				api.openWin({useWKWebView:true,
				    name: 'Teacher_Freecourse_ResearchChapter',
				    url: 'Teacher_Freecourse_ResearchChapter.html',
				    pageParam: {
				        id : data.id,
						pid : pid,
						cid : data.cid,
						cdetailtitle : data.cdetailtitle,
						rid : data.rid,
						bewrite : data.bewrite,

						is_dis_bewrite :data.is_dis_bewrite,
					    content_type :cType
				    }
				});
				return;
			// }

		}else if(cType == 'tests'){//测验
		 //    if(bewrite.length >0){
			//   	winName = 'Student_Free_bewrite';
			//   	pageParam = {
			//         id : data.id,
			// 		pid : pid,
			// 		cid : data.cid,
			// 		cdetailtitle : data.cdetailtitle,
			// 		rid : data.rid,
			// 		bewrite :data.bewrite,
			// 		isanswer :data.isanswer,
			// 		is_dis_bewrite :data.is_dis_bewrite,
			// 	    content_type :cType
			//     };
	
			// }else{
				api.openWin({useWKWebView:true,
				    name: 'Teacher_Freecourse_TestChapter',
				    url: 'Teacher_Freecourse_TestChapter.html',
				    pageParam: {
				        id : data.id,
						pid : pid,
						cid : data.cid,
						cdetailtitle : data.cdetailtitle,
						rid : data.rid,
						bewrite :data.bewrite,
						isanswer :data.isanswer,
					   	is_dis_bewrite :data.is_dis_bewrite,
					   content_type :cType
						
				    }
				});
				return;
			// }


		}else if(cType == 'discuss'){//讨论 
			winName = 'New_Student_FreeCourse_DiscussChapterWindow';
			pageParam = {
				chapterid : data.id,
				pid : pid,
				cid : data.cid,
				cdetailtitle : data.cdetailtitle,
				bewrite :data.bewrite,
				is_dis_bewrite :data.is_dis_bewrite
			};
		}else if(cType == 'works'){//作业
	
			api.openWin({useWKWebView:true,
			    name: 'Teach_Freecouse_check_homeWork',
			    url: 'Teach_Freecouse_check_homeWork.html',
			    pageParam: {
					vid : data.id,
			        pid : api.pageParam.planid,
			        cid : api.pageParam.courseid,
			        wid : data.rid,
			     	cdetailtitle : data.cdetailtitle,
			     	bewrite : data.bewrite,
			 	   is_dis_bewrite : data.is_dis_bewrite
				}
			});
			return;
		}else if(cType == 'folder'){//文件夹
//		  if(bewrite.length >0){
//			  	winName = 'Student_Free_bewrite';
//			  	pageParam = data;
//			}else{
			// winName = 'Student_FreeCourseFileNew';
			// pageParam = data;
			setupFolderFCellClick(data.id);
			return;
//			}
		}else if(cType == 'files'){//文件
//		  if(bewrite.length >0){
//			  	winName = 'Student_Free_bewrite';
//			  	pageParam = data;
//	
//			}else{
			// winName = 'Student_FreeCourseFileNew';
			// pageParam = data;
			setupFilesChapter(data);
			return;
//			}
		}else if(cType == 'sitenow'){//现场实操
		 //    if(bewrite.length >0){
			//   	winName = 'Student_Free_bewrite';
			//   	pageParam =  {
			//         id: data.id,
			//         pid: pid,
			//         cid: data.cid,
			//         cdetailtitle: data.cdetailtitle,
			//         bewrite : data.bewrite,
			// 	    is_dis_bewrite :data.is_dis_bewrite,
			// 	    content_type :cType,
			//         uid: $api.getStorage('cfnetppuid'),
			//         jid: $api.getStorage('cfnetppjxid')
			//     };
	
			// }else{
				api.openWin({useWKWebView:true,
				    name: 'new_Mark_sheetTea',
				    url: '../LivePracticeTea/new_Mark_sheetTea.html',
				    pageParam: {
				        id: data.id,
				        pid: pid,
				        cid: data.cid,
				        uid: $api.getStorage('cfnetppuid'),
				        jid: $api.getStorage('cfnetppjxid')
				    }
				});
				return;
			// }
		}else if(cType == 'hdresource'){//互动资源
			
   //          if(bewrite.length >0){
			//   	winName = 'Student_Free_bewrite';
			//   	pageParam = data;
	
			// }else{
				if(api.connectionType == 'none'){
					api.toast({
				    	msg: '暂无网络，无法访问该内容'
					});
					return;
			  	}
			   	winName = 'student_study_freecourse_interactiveNew';
			   	pageParam = data;
			// }
		 	pageParam["type"] = 1;
		}else if(cType == 'tag'){//标签
		 //    if(bewrite.length >0){
			//   	winName = 'Student_Free_bewrite';
			//   	pageParam = data;
	
			// }else{
		 //       	api.toast({
			//     msg: '该标签暂无描述内容',
			//     duration: 3000,
			//     location: 'bottom'
			// });
		 //  }
			return;
		}else{
			api.toast({
			    msg: '手机不支持该类型，请在电脑上查看'
			});
			return;
		}
//		 alert(JSON.stringify(pageParam));

		// if(winName=='New_student_study_freecourse_TestExam'||winName=='New_student_study_freecourse_TestScore'||winName=='New_Student_Study_ResearchExam'||winName=='New_Student_Study_ResearchScore'){
			api.openWin({useWKWebView:true,
			    name: winName,
			    url: '../Study/' + winName + '.html',
			    pageParam: pageParam,
			    slidBackEnabled :false
			});
			SendBehaviorTrajectoriesNotifi(1, '章节列表', '028');
		// }else{
		// 	api.openWin({useWKWebView:true,
		// 	    name: winName,
		// 	    url: winName + '.html',
		// 	    pageParam: pageParam
		// 	});
		// }
	}
	function setupFilesChapter(data){
		var is_encr = data.is_encr;
		var baidu_cloud_id_url = data.baidu_cloud_id_url;
		var baidu_cloud_id = data.baidu_cloud_id;
		var rid = data.rid;
		var ridArr = rid.split('||');
		var title = ridArr[0];
		var doc = ridArr[1];
		var arr = new Array('jpg', 'png', 'jpeg', 'bmp');
		var gifArr = new Array('gif');
		var arr1 = new Array('swf', 'mp4');
		var ext = doc.replace(/.+\./, "");
		if (gifArr.toString().indexOf(ext) > -1){
			openGif(doc);
		}else if (arr.toString().indexOf(ext) > -1) {
			openImage(doc);
		} else {
			if (arr1.toString().indexOf(ext) > -1) {
				var connectionType = api.connectionType;
	            if (connectionType != 'wifi' && connectionType != 'none') {
	            	api.confirm({
	                    title: '提示',
	                    msg: '您当前处于移动数据网络下，是否继续播放',
	                    buttons: ['确定', '取消']
	                }, function(ret, err) {
	                    var index = ret.buttonIndex;
	                    if (index == 1) {//确定
	                        // openVideoWin(doc, title);
	                        pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, doc, title);
	                    }
	                });
	            }else{
	            	// openVideoWin(doc, title);
	            	pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, doc, title);
	            }
			} else {
				if (is_encr == 1) {//加密
					var CFBaiDuDoc = api.require('CFBaiDuDoc');
			        CFBaiDuDoc.startDocActivityForResult({
			            docId:baidu_cloud_id,//文档ID
			            title:title,//文档标题
			            token:"TOKEN",//文档token，离线加载时不验证。
			            host:"BCEDOC",//文档所属站点
			            docType:"doc" //文档类型，可取值为ppt 和 doc
			        },function(){
			        });
				}else{
					api.openWin({useWKWebView:true,
						name : 'Student_FreeCourseDoc',
						url : '../Study/Student_FreeCourseDoc.html',
						pageParam : {
							title : title,
							doc : doc
						}
					});
				}
			}
		}	
	}
	function toPlayVideo(data){
		// api.confirm({
		//     title: '请选择播放器',
		//     buttons: ['阿里云播放器', '百度云播放器']
		// }, function(ret, err) {
		//     var index = ret.buttonIndex;
		//     if (index == 1) {
		//     	openALiWebVideo(data);
		//     }else{
		//     	openBaiDuWebVideo(data);
		//     }
		// });
		// return;
		
		// api.openWin({useWKWebView:true,
		//     name: 'Student_FreeCourseVideoPlayer',
		//     url: 'Student_FreeCourseVideoPlayer.html',
		//     pageParam: {
		//         videoUrl : data.rid,
		//         title : data.cdetailtitle
		//     }
		// });
		// var h = 240;
		// api.openFrame({
		//     name: 'HTML5VideoPlayer',
		//     url: '../Teacher_Teach/HTML5VideoPlayer.html',
		//     rect: {
		//         x: 0,
		//         y: 0,
		//         w: 'auto',
		//         h: h
		//     },
		//     pageParam:{
		//     	videoUrl : data.rid
		//     },
		//     reload : true
		// });
		// return;
		var videoPlayer = api.require('videoPlayer');
		videoPlayer.play({
		    path : data.rid,
		    texts: {
		        head: {
		            title: data.cdetailtitle
		        }
		    },
		    styles : {
		    	head : {
		    		backSize : 24,
		    		backImg : 'widget://image/vp_back.png',
		    		setSize : 24,
		    		setImg : 'widget://image/vp_more.png'
		    	},
		    	foot :{
		    		playSize : 24,
		    		playImg : 'widget://image/vp_play.png',
		    		pauseImg : 'widget://image/vp_pause.png',
		    		nextSize : 24,
		    		nextImg : 'widget://image/vp_next.png'
		    	}
		    }
		}, function(ret, err) {
	        
		});
	}
	function openALiWebVideo(data){
		var height = api.winHeight - 44;
		api.openFrame({
		    name: 'ALiWebVideo',
		    url: '../Study/ALiWebVideo.html',
		    rect: {
		        x: 0,
		        y: 44,
		        w: 'auto',
		        h: height
		    },
		    pageParam: {
		        videoUrl : data.rid,
		        title : data.cdetailtitle
		    },
		    bounces: false
		});
	}
	function openBaiDuWebVideo(data){
		var width = api.winWidth;
		var height = width * 3 / 4;
		api.openFrame({
		    name: 'BaiDuWebVideo',
		    url: '../Study/BaiDuWebVideo.html',
		    rect: {
		        x: 0,
		        y: 44,
		        w: 'auto',
		        h: height
		    },
		    pageParam: {
		        videoUrl : data.rid,
		        title : data.cdetailtitle
		    },
		    bounces: false
		});
	}
	function menuClick(){
		$('#menu_btn').hide();
		api.openFrame({
		    name: 'course_add_menu',
		    url: '../Study/course_add_menu.html',
		    rect: {
		        x: 0,
		        y: 0,
		        w: 'auto',
		        h: 'auto'
		    },
		    pageParam: {
		        name: api.pageParam
		    }
		});
	}
</script>
</html>